﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AlmaDatabase;

namespace Alma.Models
{
    public class HomeCategory
    {
        public string ImageName { get; set; }
        public string Name { get; set; }
        public long Id { get; set; }
    }

    public class HomeModel
    {
        public IList<HomeCategory> Categories { get; set; }
        public List<CategoryModel> catList { get; set; }
        public List<Product> Similars { get; set; }

        public HomeModel()
        {
            catList = new List<CategoryModel>();
            Similars = new List<Product>();

            using (var context = new AlmaDBEntities())
            {
                var cat = from cats in context.Categories
                          select cats;
                foreach (var c in cat)
                catList.Add(new CategoryModel(c));

                var product = from products in context.Products
                              orderby products.ID descending
                              select products;
                foreach (var p in product.Take(8))
                    Similars.Add(p);
            }
        }
    }
}
